import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from "path"
import dts from 'vite-plugin-dts'

export default defineConfig(({mode}) => {
  return {
    plugins: [
      react(),
      dts({
        include: [
          'components/index.ts',
          'components/**/*.{ts,tsx}'
        ],
      })
    ],
    server: {
      open: true,
    },
    resolve: {
      alias: {
        '@hs-component': resolve(__dirname, '')
      }
    },
    build: {
      lib: {
        entry: resolve(__dirname, 'components/index.ts'),
        formats: ['es'],
        fileName: 'index'
      },
      outDir: 'hs-component/es',
      rollupOptions: {
        external: ["react", "react-dom", "react/jsx-runtime"]
      }
    },
  }
})
